﻿var TMM = {};

TMM.Global = (function () {
    var self = this;
    var global = null;

    var currentCulture = $("#CurrentCulture").val();

    this.translate = function (key) {
        if (!key)
            return '';

        if (!global)
            global = new Globalize(currentCulture);

        return global.localize(key) || key;
    };

    this.getCultureDefinition = function () {
        return Globalize.cultures[currentCulture];
    };

    this.format = function (value, format, cultureSelector) {
        if (!global)
            global = new Globalize(currentCulture);

        return global.format(value, format, cultureSelector);
    };

    return {
        translate: function (key) { return self.translate(key); },
        getCultureDefinition: function () { return self.getCultureDefinition(); },
        getCalendarPatterns: function () { return self.getCultureDefinition().calendars.standard.patterns; },
        getMonths: function (abbreviated) { var months = self.getCultureDefinition().calendars.standard.months; return abbreviated ? months.namesAbbr : months.names; },
        getDays: function (abbreviated) { var days = self.getCultureDefinition().calendars.standard.days; return abbreviated ? days.namesShort : days.names; },
        format: function (value, format, cultureSelector) { return self.format(value, format, cultureSelector); }
    };
})();